<template>
	<el-container>
		<el-header style="height: auto;">
			<sc-select-filter :data="filterData" :label-width="80" @on-change="filterChange"></sc-select-filter>
		</el-header>
		<el-header>
			<div class="left-panel">
			</div>
			<div class="left-panel"> </div>
			<div class="right-panel">
				<div class="right-panel-search">
					<el-input v-model="search.keyword" placeholder="名称 / 编号" clearable></el-input>
					<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
				</div>
			</div>
		</el-header>
		<el-main class="nopadding">
			<scTable ref="table" :apiObj="apiObj" row-key="proId" stripe remoteSort remoteFilter>
				<el-table-column label="#" type="index" width="50"></el-table-column>
				<el-table-column label="项目编号" prop="proCode" width="200" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column label="项目名称" prop="title" width="300" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column label="项目分类" prop="sortName" width="100"></el-table-column>
				<el-table-column label="项目等级" prop="proLevelName" width="100"></el-table-column>
				<el-table-column label="开始时间" prop="beginTime" width="150"></el-table-column>
				<el-table-column label="结束时间" prop="endTime" width="100"></el-table-column>
				<el-table-column label="项目经理" prop="managerUserName" width="100"></el-table-column>
				<el-table-column label="当前状态" prop="status" width="100">
					<template #default="scope">
						<el-tag type="danger" size="small" v-if="scope.row.status=='0'">立项中</el-tag>
						<el-tag type="warning" size="small" v-else-if="scope.row.status=='1'">已驳回</el-tag>
						<el-tag type="success" size="small" v-else-if="scope.row.status=='2'">审批中</el-tag>
						<el-tag type="primary" size="small" v-else-if="scope.row.status=='3'">处理中</el-tag>
						<el-tag type="warning" size="small" v-else-if="scope.row.status=='4'">已挂起</el-tag>
						<el-tag type="success" size="small" v-else-if="scope.row.status=='5'">已完成</el-tag>
						<el-tag type="info" size="small" v-else>未知</el-tag>
					</template>
				</el-table-column>
				<el-table-column label="操作" fixed="right" align="right" width="100">
					<template #default="scope">
						<el-button-group>
							<el-button text type="primary" size="small" @click="table_show(scope.row, scope.$index)">查看</el-button>
						</el-button-group>
					</template>
				</el-table-column>
			</scTable>
		</el-main>
	</el-container>
	<recordDetails v-if="dialog.detailsSave" ref="detailsDialog" @closed="dialog.detailsSave=false"></recordDetails>
</template>

<script>
import scSelectFilter from '@/components/scSelectFilter'
import recordDetails from '@/views/project/initiation/details'
export default {
	name: 'Project Query Manage',
	components: {
		scSelectFilter,
		recordDetails
	},
	data() {
		return {
			dialog: {
				save: false,
				detailsSave:false,
			},
			filterData: [
				{
					title: "日期范围",
					key: "date",
					multiple: false,
					options: [
						{
							label: "全部",
							value: ""
						},
						{
							label: "今日",
							value: "1"
						},
						{
							label: "昨日",
							value: "2"
						},
						{
							label: "一周内",
							value: "3"
						},
						{
							label: "一月内",
							value: "4"
						},
						{
							label: "一月前",
							value: "5"
						}
					]
				},
				{
					title: "项目类型",
					key: "proSort",
					multiple: false,
					options:[{
						label: "全部",
						value: ""
					}]
				},
				{
					title: "项目级别",
					key: "proLevel",
					multiple: false,
					options:[{
						label: "全部",
						value: ""
					}]
				},
				{
					title: "项目状态",
					key: "status",
					multiple: false,
					options:[{
						label: "全部",
						value: ""},
						{
							label: "立项中",
							value: "0"},
						{
							label: "已驳回",
							value: "1"},
						{
							label: "审批中",
							value: "2"},
						{
							label: "处理中",
							value: "3"},
						{
							label: "已挂起",
							value: "4"},
						{
							label: "已办结",
							value: "5"},
					]
				},
			],
			apiObj: this.$API.project.proRecord.getProRecordListByQuery,
			search: {
				date:'',
				proLevel:'',
				status:'',
				keyword: null
			}
		}
	},
	mounted() {
		this.getProSort();
	},
	methods: {
		async getProSort()
		{
			var res = await this.$API.project.proSort.getProSort.get();
			if (res.code == 200) {
				this.filterData[1].options=this.filterData[1].options.concat(res.data);
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
			res = await this.$API.project.proDic.getProDicByCode.get({code:'proLevel'});
			if (res.code == 200) {
				this.filterData[2].options=this.filterData[2].options.concat(res.data);
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		filterChange(data){
			this.search.date = data.date;
			this.search.proLevel = data.proLevel;
			this.search.status = data.status;
			this.$refs.table.upData(this.search)
		},
		//查看
		table_show(row) {
			this.dialog.detailsSave = true
			this.$nextTick(() => {
				this.$refs.detailsDialog.open().setData(row)
			})
		},
		//搜索
		async upsearch() {
			this.$refs.table.upData(this.search)
		},
	}
}
</script>

<style>
</style>
